/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControllerLag;
import ModelLag.*;
import DBLag.*;
import java.util.ArrayList;

/**
 * Controllerklasse for Event.
 * @author DM75 Gruppe 3
 * @version 2011-12-22
 */
public class EventCTR {
        private IFDbEvent dbEvent;

        public EventCTR()
    {
        dbEvent = new DbEvent();
    }
    
        /**
         * Finder event via eventName.
         * @param eventName
         * @return
         */
        public Event findEvent(String eventName)
    {
        return dbEvent.findEvent(eventName);
    }
    
    
        /**
         * Opretter event via eventName, pricePrPerson og pricePrPersonOnlyFood
         * @param eventName
         * @param pricePrPerson
         * @param pricePrPersonOnlyFood
         * @return
         */
        public int createEvent(String eventName, double pricePrPerson, double pricePrPersonOnlyFood)
    {
        Event eventObj = new Event(eventName, pricePrPerson, pricePrPersonOnlyFood);
        return dbEvent.insertEvent(eventObj);
    }
    
    /**
     * Opdatering af et Event
     * @param eventName
     * @param pricePrPerson
     * @param pricePrPersonOnlyFood
     * @return
     */
    public int updateEvent(String eventName, double pricePrPerson, double pricePrPersonOnlyFood)
    {
        Event eventObj = new Event();
        eventObj.setEventName(eventName);
        eventObj.setPricePrPerson(pricePrPerson);
        eventObj.setPricePrPersonOnlyFood(pricePrPersonOnlyFood);
//        Event newEvent = new Event(eventName, pricePrPerson, pricePrPersonOnlyFood);
//        return dbEvent.updateEvent(newEvent);
        
        return dbEvent.updateEvent(eventObj);
    }
    
    /**
     * sletter Event
     * @param eventName
     * @return
     */
    public int deleteEvent(String eventName)
    {
        return dbEvent.deleteEvent(eventName);
    }
    
    /**
     * Henter alle events
     * @return
     */
    public ArrayList<Event> getAllEvent()
    {
        return dbEvent.getAllEvent();
    }
    
}
